package com.service.impl;

import com.domain.Gallery;
import com.domain.GalleryImg;
import com.mapper.GalleryMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GalleryServiceImpl {
    @Resource
    private GalleryMapper galleryMapper;
    //查找置顶画廊数据
    public List<Gallery> findTopGallery(){
        return galleryMapper.findTopGallery();
    }
    //获取gallery数据
    public List<Gallery> findAllGallery() {
        return galleryMapper.findAllGallery();
    }
    //获取对应gallery的img数据
    public List<GalleryImg> findGalleryImg(int gid) {
        return galleryMapper.findGalleryImg(gid);
    }
    //删除img
    @Transactional
    public void deleteGalleryImg(int id) {
        galleryMapper.deleteGalleryImg(id);
    }
    //修改gallery描述信息
    @Transactional
    public int updateGalleryMsg(Gallery gallery) {
        return galleryMapper.updateGalleryMsg(gallery);
    }
    //删除gallery（为空）
    @Transactional
    public void deleteGallery(int g_id) {
        galleryMapper.deleteGallery(g_id);
    }
    //上传图片
    @Transactional
    public void addGalImg(GalleryImg galleryImg) {
        galleryMapper.addGalImg(galleryImg);
    }
    //新建gallery
    @Transactional
    public int addGallery(Gallery gallery) {
        return galleryMapper.addGallery(gallery);
    }
}
